package com.hmall.item.search.listen;


import com.hmall.common.pojo.Item;
import com.hmall.item.search.constant.MqConstants;
import com.hmall.item.search.service.SearchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author 29143
 */
@Component
@Slf4j
public class ItemListener {
    @Autowired
    private SearchService searchService;

    @RabbitListener(queues = MqConstants.ITEM_DELETE_QUEUE)
    public void deleteItem(String id){
        searchService.deleteById(id);
    }

    @RabbitListener(queues = MqConstants.ITEM_INSERT_QUEUE)
    public void insertById(String id){
        searchService.insertById(id);
    }

}
